﻿using Aeon.Emulator.Sound.FM.Operators;

namespace Aeon.Emulator.Sound.FM.Channels
{
    /// <summary>
    /// Emulates a 2-operator rhythm OPL channel.
    /// </summary>
    internal sealed class RhythmChannel : Channel2
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="RhythmChannel"/> class.
        /// </summary>
        /// <param name="baseAddress">The base address of the channel's control registers.</param>
        /// <param name="operator1">The first operator in the channel.</param>
        /// <param name="operator2">The second operator in the channel.</param>
        /// <param name="opl">The synthesizer which owns the channel.</param>
        public RhythmChannel(int baseAddress, StandardOperator operator1, StandardOperator operator2, FmSynthesizer opl)
            : base(baseAddress, operator1, operator2, opl)
        {
        }

        /// <summary>
        /// Returns an array containing the channel's output values.
        /// </summary>
        /// <returns>Array containing the channel's output values.</returns>
        protected override double GetChannelOutput()
        {            
            return (this.operator1.GetOperatorOutput() + this.operator2.GetOperatorOutput()) / 2.0;
        }
        /// <summary>
        /// Activates channel output.
        /// </summary>
        protected override void KeyOn()
        {
        }
        /// <summary>
        /// Disables channel output.
        /// </summary>
        protected override void KeyOff()
        {
        }
    }
}
